package ldh.im.dto.codec;

import io.netty.buffer.ByteBuf;
import ldh.im.dto.base.Dto;
import ldh.im.util.ByteBufHelp;

import java.nio.charset.Charset;

public abstract class BaseImCoder<T extends Dto> extends ByteBufImCoder<T> {

    public static final Charset utf8 = Charset.forName("utf8");

    public void writeString(ByteBuf byteBuf, String str) {
        ByteBufHelp.writeString(byteBuf, str, utf8);
    }

    public String readString(ByteBuf byteBuf) {
        return ByteBufHelp.readString(byteBuf, utf8);
    }

    public char[] readChars(ByteBuf byteBuf) {
        return ByteBufHelp.readChars(byteBuf);
    }

    public void writeChars(ByteBuf byteBuf, char[] chars) {
        ByteBufHelp.writeChars(byteBuf, chars);
    }

}
